<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>CSC560 Design and Analysis of Real-Time Systems</title>
<meta name="keywords" content="CSC560" />
<meta name="description" content="CSC560" />
<link href="../default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
	<div id="header">
		<h1>CSC560</h1>
		<h2>Design and Analysis of Real-Time Systems</h2>
		<ul>
			<li class="first"> <a href="../index.html" accesskey="1" title="">Home</a> </li>
			<li> <a href="../project1/index.html" accesskey="2" title="">Project 1</a>	</li>
			<li> <a href="../project2/index.html" accesskey="3" title="">Project 2</a> </li>
			<li> <a href="../project3/index.html" accesskey="4" title="">Project 3</a> </li>
			<li> <a href="index.html" accesskey="4" title=""><b>Project 4</b></a> </li>
			<li> <a href="../project5/index.html" accesskey="4" title="">Project 5</a> </li>
		</ul>
	</div>
</div>
<div id="content">
	<div id="colOne">
		<h2>Finite State Machines</h2>
		<p>
			In this section, we present finite state machines that are necessary to model
			the behavior of the cat and the mouse. The first two finite state machines model the behavior
			of the cat, and the third models the behavior of the mouse. For each 
			finite state machine, we identify and explain the states and transitions through which the cat or 
			the mouse go through at a given moment. Please click on the image to enlarge.
			
		</p>
		<h3>Cat Finite State Machines</h3>
		<p>
			We have divided the cat finite state machine into two parts so that it is easier 
			to explain and understand. In reality, the following two finite state machines are a single entity.
		</p>
		<center>
		<a href="images/fsm_cat1.jpg"><img src="images/fsm_cat1.jpg" width = "100%"></a>
		FSM: Cat
		</center>
		<ul>
			<li><i><b>Init</i></b><br>
				<i>Init</i> is the first state the cat gets into when the program starts. 
			</li>
			<li> <i><b>Wait for begin</i></b><br>
				<i>Wait for begin</i> state happens when the cat is waiting for the mouse to acknowledge that 
				it is ready to start the game. 
			</li>
			<li> <i><b>Searching</i></b><br>
				<i>Searching</i> is the state where the cat is looking for the mouse. It performs certain movement
				commands that will be explained in the next finite state machine.
			</li>
			<li> <i><b>Chasing</i></b><br>
				<i>Chasing</i> is the state in which the cat has detected the mouse and is performing movement commands
				in order to catch the mouse. This state will be explained in details in the next finite state machine.
			</li>
			<li> <i><b>Collision</i></b><br>
				<i>Collision</i> state happens when the cat has collided with an object. It can either be the mouse 
				or any other physical object.
			</li>
			<li> <i><b>Wait for status</i></b><br>
				<i>Wait for status</i> is the state in which the cat is waiting for the mouse to respond with crucial 
				information needed to dertermine whether the cat has bumped the mouse. The information contained in
				the status is the mouse's bumper information and sensor activity. In order to conclude that the cat has 
				collided with the mouse, the cat must know whether the mouse has been bumped by the cat,
				and whether the mouse sensor activated. If this is the case, then the cat has bumped into the cat.
				Having both the mouse bumper and sensor activated eliminate potential errors in collision detection.
				For instance, the cat and mouse could both have bumped into a wall at the same time. Then the cat 
				would ask the mouse whether it has been bumped, and the mouse would answer positively. Therefore, by
				asking the mouse to also sensor activity, then we can be sure that the cat has indeed bumped into the 
				cat.
			</li>
			<li> <i><b>Mouse Captured</i></b><br>
			<i>Mouse captured</i> state happens when the cat knows that the mouse bumper and sensor is activated.
			</li>
			<li> <i><b>Game over</i></b><br>
				<i>Game over</i> is the state that happens when the cat has won or lost the game.
			</li>
		</ul>
		<center>
		<a href="images/fsm_cat2.jpg"><img src="images/fsm_cat2.jpg" width = "100%"></a>
		FSM: Searching and Chasing states of the Cat
		</center>
		<ul>
			<li><i><b>Searching</i></b><br>
				<i>Searching</i> happens when the cat sensor is not activated. When the cat
				is in this state, it executes random movement commands to search for the mouse.
			</li>
			<li><i><b>Chasing</i></b><br>
				<i>Chasing</i> happens when the cat has detected the mouse. At that time,
				the cat will be making movements in the direction of the mouse. We expect 
				that the cat will often move back and forth between chasing and searching mode. 
			</li>
			<li><i><b>Movement states: Forward, backward, left, and right</i></b><br>
			The movement states specify which direction is the cat searching or chasing.
			If the cat is in searching mode, it will randomly choose a movement direction.
			We have decided that a movement will be randomly chosen by taking modulo 4
			of the time. If the modulo is 0, the cat will enter <i>move left</i> state, if 
			the modulo is 1 the cat will enter <i>move backward</i> state, and similarly for 
			the other directions. If the cat is in chasing mode, it will execute movement commands
			whenever it detects the presence of the mouse. Therefore, it will move towards the left
			if its sensor located on the left of the roomba detects the mouse.
			</li>
		</ul>
		<h3>Mouse Finite State Machine</h3>
		<p> 
		<a href="images/fsm_mouse.jpg"><img src="images/fsm_mouse.jpg" width = "100%"></a>
		FSM: Mouse		
		<ul>
			<li><i><b>Init</i></b><br>
				<i>Init</i> is the first state the mouse gets into when the program starts.
			</li>
			<li><i><b>Cheesing</i></b><br>
				<i>Cheesing</i> happens when the mouse sends a begin message to the cat. At this time,
				the mouse starts the game and starts the timer before getting into cheesing mode. In cheesing mode, 
				the roomba operates in vaccuming mode. Vaccuming mode simulates the search for cheese.
			</li>	
			<li><i><b>Verify Status</i></b><br>
				<i>Verify Status</i> happens when the mouse must verify if the bumper and the sensor
				has been activated.
			</li>
			<li><i><b>Time's up</i></b><br>
				<i>Time's up</i> happens when the timer expires. At this time, the mouse has won the game 
				and is ready to advertise the mouse that it is the winner.
			</li>
			<li><i><b>Not Bumped</i></b><br>
				<i>Not Bumped</i> happens when the mouse knows that it has not been bumped by the cat.
			</li>
			<li><i><b>Mouse Captured</i></b><br>
				<i>Mouse Captured</i> happens when the mouse gets into the state where it has been captured by the cat.
			</li>
			<li><i><b>Wait for game over</i></b><br>
				<i>Wait for game over</i> happens when the mouse sends the positive status information. At that
				time it knows that it has lost the game.
			</li>
			<li><i><b>Game over</i></b><br>
				<i>Game over</i> happens when the mouse has either won or lost the game.
			</li>
		</ul>
		</p>
	</div>
	<div id="colTwo">
		<h3>Project Sections</h3>
		<ul>
			<li class="first"><a href="01_game_rule.html">Game Rules</a></li>
			<li><a href="02_hardware_description.html">Hardware Description</a></li>
			<li><a href="03_design_process.html">Design Process</a></li>
			<li>-	<a href="03_a_block_diagram.html">Block Diagram</a></li>
			<li>-	<a href="03_b_msc.html">Message Sequence Charts</a></li>
			<li>-	<a href="03_c_fsm.html">Finite State Machines</a></li>
			<li>-	<a href="03_d_timing_diagram.html">Timing Diagrams</a></li>
			<li><a href="04_extra_features.html">Potential Extra Features</a></li>
		</ul>
	</div>
</div>
<div id="footer">
	<p>
		@ 2009. All Rights Reserved. Design by 
		<a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.
	</p>
</div>
</body>
</html>
